#pragma once

#include "Utility.h"
#include "Type.h"

namespace Common
{
	//TODO: should be in seperated thread and user can input the log object into log bump
	class LogManager
		: public Singleton<LogManager>
	{
	public:

		enum Level
		{
			eInfo,
			eWarning,
			eError,
			eFatal
		};

		class LogListener
		{
		public:
			LogListener( LogManager* pOwner );
			virtual ~LogListener(void);

			virtual void OnOutputMsg( const String& rOutputMsg ) = 0; 
		};

		typedef std::vector< LogListener* >			LogListeners;
		typedef LogListeners::iterator				LogListenersIterator;
		typedef LogListeners::const_iterator		LogListenersConstIterator;

		LogManager(void);
		~LogManager(void);

		template<class Type>
		LogManager& operator<< ( const Type& val )
		{
			m_stream << val;
			return *this;
		}

		template<class Type>
		LogManager& operator<< ( Type& val )
		{
			m_stream << val;
			return *this;
		}

		void outputMsg( bool bClearStreamBuff = true );

	private:

		StringStream	m_stream;
	};
}